package com.banshuibao.bsb_android.activity;

import android.os.Bundle;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.banshuibao.bsb_android.Constants;
import com.banshuibao.bsb_android.R;

public class AboutUsActivity extends BaseActivity {
    private WebView webView;
    private WebViewClient client = new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return super.shouldOverrideUrlLoading(view, url);
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        initView();
    }

    public void initView() {
        setTitleText("关于我们");
        webView = findViewById(R.id.about_us);
        requestNet();
    }

    public void requestNet() {
        webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webView.requestFocus();
        webView.setWebViewClient(client);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl(Constants.Url.ABOUT_US);
        //   webView.loadDataWithBaseURL(null, Constants.Url.ABOUT_US, "text/html", "utf-8", null);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (webView != null) {
            //webView.getSettings().setJavaScriptEnabled(false);
            if (webView.getParent() != null) {
                ((ViewGroup) webView.getParent()).removeView(webView);
            }
            webView.removeAllViews();
            webView.clearHistory();
            webView.destroy();
            webView = null;
        }
    }
}
